package com.hl;

import com.hl.entity.Teacher;
import com.hl.mapper.TeacherMapper;
import com.hl.util.MybatisUtils;
import org.apache.ibatis.session.SqlSession;

import java.io.IOException;
import java.util.List;

/**
 * 二级缓存测试
 * */
public class Test8Cache2 {
    public static void main(String[] args) throws IOException {
        SqlSession sqlSession = MybatisUtils.getSqlSession();
        TeacherMapper mapper = sqlSession.getMapper(TeacherMapper.class);
        mapper.selectAllTeachers();
        List<Teacher> list1 = mapper.selectAllTeachers();
        for (Teacher teacher : list1) {
            System.out.println(teacher);
        }
        MybatisUtils.closeSqlSession(sqlSession);
        SqlSession sqlSession2 = MybatisUtils.getSqlSession();
        TeacherMapper mapper2 = sqlSession2.getMapper(TeacherMapper.class);
        List<Teacher> list2 = mapper.selectAllTeachers();
        for (Teacher teacher : list2) {
            System.out.println(teacher);
        }
        mapper2.selectAllTeachers();

    }
}
